/**
  ******************************************************************************
  * @file    spi_sdcard.h
  * @author  YANDLD
  * @version V3.0
  * @date    2016.05.29
  * @brief   www.beyondcore.net   http://upcmcu.taobao.com
  ******************************************************************************
  */

#ifndef __SPI_SDCARD_H__
#define __SPI_SDCARD_H__

#include <stdint.h>

enum
{
    kCard_Unknow,
    kCard_SDHC,
    kCard_SDv2,
};


struct sdcard_init_t
{
    uint32_t (*send)(uint8_t *buf, uint32_t len, uint8_t cs);
    uint32_t (*recv)(uint8_t *buf, uint32_t len, uint8_t cs);
};


int spi_sdcard_init(struct sdcard_init_t* init);
uint32_t sdcard_get_size_mb(void);
uint32_t sdcard_read_single_block(uint32_t sector, uint8_t *buf);
uint32_t sdcard_write_single_block(uint32_t sector, uint8_t *buf);
uint32_t sdcard_read_multi_block(uint32_t sector, uint8_t *buf, uint32_t cnt);
uint32_t sdcard_write_multi_block(uint32_t sector, uint8_t *buf, uint32_t cnt);



#endif



